clear all;
clc;

% ------------------------ Importing Results ------------------------------

pol = 1;
if(pol == 1)
    ptag = 'pos_';
else
    ptag = 'neg_';
end

epi_mp_dc = load([ptag,'epi_mp_dc_thresh_100axons_312nodes_9um.txt']);
epi_mp_dc(:,1) = sort(pol*epi_mp_dc(:,1));
epi_mp_dr = load([ptag,'epi_mp_dr_thresh_100axons_167nodes_9um.txt']);
epi_mp_dr(:,1) = sort(pol*epi_mp_dr(:,1));

sub_mp_dc = load([ptag,'sub_mp_dc_thresh_100axons_312nodes_9um.txt']);
sub_mp_dc(:,1) = sort(pol*sub_mp_dc(:,1));
sub_mp_dr = load([ptag,'sub_mp_dr_thresh_100axons_167nodes_9um.txt']);
sub_mp_dr(:,1) = sort(pol*sub_mp_dr(:,1));

epi_bp_dc = load([ptag,'epi_bp_dc_thresh_100axons_312nodes_9um.txt']);
epi_bp_dc(:,1) = sort(pol*epi_bp_dc(:,1));
epi_bp_dr = load([ptag,'epi_bp_dr_thresh_100axons_167nodes_9um.txt']);
epi_bp_dr(:,1) = sort(pol*epi_bp_dr(:,1));

sub_bp_dc = load([ptag,'sub_bp_dc_thresh_100axons_312nodes_9um.txt']);
sub_bp_dc(:,1) = sort(pol*sub_bp_dc(:,1));
sub_bp_dr = load([ptag,'sub_bp_dr_thresh_100axons_167nodes_9um.txt']);
sub_bp_dr(:,1) = sort(pol*sub_bp_dr(:,1));

% ------------------------- Percent/Percent -------------------------------

[m,n] = size(epi_mp_dc);

msub = 1:1:m;

% f1 = perp ppln
% f2 = para ppln
epimp_f1v2  = pera_vs_perb(epi_mp_dc(:,1),epi_mp_dr(:,1));
submp_f1v2  = pera_vs_perb(sub_mp_dc(:,1),sub_mp_dr(:,1)); 
epibp_f1v2 = pera_vs_perb(epi_bp_dc(:,1),epi_bp_dr(:,1)); 
subbp_f1v2 = pera_vs_perb(sub_bp_dc(:,1),sub_bp_dr(:,1)); 

figure;
hold on;
plot(0:100,0:100,'k-','LineWidth',3);
plot(epimp_f1v2(msub,1),epimp_f1v2(msub,2),'k--','LineWidth',3,'MarkerSize',10);
plot(submp_f1v2(msub,1),submp_f1v2(msub,2),'k.-','LineWidth',2,'MarkerSize',30);
plot(epibp_f1v2(msub,1),epibp_f1v2(msub,2),'k^-','LineWidth',2,'MarkerSize',10);
plot(subbp_f1v2(msub,1),subbp_f1v2(msub,2),'kx-','LineWidth',2,'MarkerSize',10);
ttl = 'Selective Activation of Dorsal Columns';
title(ttl,'FontSize',30,'FontWeight','b');
xlabel('Dorsal Columns Activated (%)','FontSize',30);
ylabel('Dorsal Roots Activated (%)','FontSize',30);
L1 = 'Monopolar Epidural';
L2 = 'Monopolar Subdural';
L3 = 'Bipolar Epidural';
L4 = 'Bipolar Subdural';
legend('No Selectivity',L1,L2,L3,L4,'Location','NEO');
set(gca,'FontSize',25);
set(gca,'XTick',0:25:100,'YTick',0:25:100);
axis square;

